package test.visualtests;

import java.util.ArrayList;

import javax.swing.JFrame;
import javax.swing.table.DefaultTableModel;

import table.MultiLineTable;
import table.headercreator.HeaderTree;
import table.model.SimpleColumn;
import table.view.multirowheader.GroupableTableColumnModel;

public class PlainColumns extends JFrame {
	
	public PlainColumns()
	{
		setTitle("Test MultiLineTable");
		DefaultTableModel dm = new DefaultTableModel();
        dm.setDataVector(new Object[][]{
            { "119"  , "Finbar" , "John"  , "Saunders" , "ja"     , "ko", "zh","row0"},
            { "911"  , "Roger"  , "Peter" , "Melly"    , "en"     , "fr", "pt","row1"}},
new Object[]{ "SNo." , "First"  , "1"     , "2"        , "Native" , "2" , "3","last"});
        
        GroupableTableColumnModel cm = new GroupableTableColumnModel();
        
 	   for(int i=0;i<dm.getColumnCount();i++)
	   {
		   SimpleColumn curCol = new SimpleColumn(i,dm.getColumnName(i));
		   cm.addColumn(curCol);
	   }
        
        MultiLineTable table = new MultiLineTable(dm,cm);
        
        HeaderTree columnTree = new HeaderTree(cm,table);
        
		ArrayList<SimpleColumn> toMerge = new ArrayList<SimpleColumn>();
		toMerge.add(columnTree.headers.get(1));
		toMerge.add(columnTree.headers.get(2));
		try
		{
			columnTree.mergeColumns("Test1", toMerge.toArray());
		} catch (Exception e){}
		
		toMerge.clear();
		toMerge.add(columnTree.headers.get(1));
		toMerge.add(columnTree.headers.get(2));
		try
		{
			columnTree.mergeColumns("Test2", toMerge.toArray());
		} catch (Exception e){}
		
        table.fireTableStructureChanged();
        getContentPane().add( table );
        setSize( 800, 600 );
        
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);
		
	}
	public static void main(String[] args) {
		new PlainColumns();
	}

}
